Lab 8: shell integration Agenda * starting Vim - command line arguments * calling native commands * filtering text with a native command * creating scripts with Vim * usage examples # command line arguments vim [file]... start vim with the supplied files loaded into buffers vim -- [file]... nothing past the "--" will be interpreted as flags [cmd] | vim - run [cmd] and load the resulting output into vim vim -h vim startup flags quick help :help starting.txt vim startup arguments full help :help arguments vim startup arguments full help vim -o [file]... open the files in a horizontal split vim -O [file]... open the files in a vertical split vim -o[n] [file]... open a horizontal split with [n] panes vim -O[n] [file]... open a vertical split with [n] panes vim -c [cmd] run ex-command on startup vim --cmd [cmd] run ex-command on startup vim + jump to last line on startup vim +[n] jump to line [n] on startup vim +[cmd] run ex-command on startup vim --clean don't load the vimrc, use the defaults instead vim -u [vimrc] specify which vimrc to use # embedded terminal :terminal open a terminal (horizontal split) :term open a terminal (horizontal split) :vertical terminal open a terminal (vertical split) :vert term open a terminal (vertical split) # interacting with the shell :![cmd] call a native command :!! repeat last shell command :read ![cmd] call a native command, insert output at cursor position :0read ![cmd] call a native command, insert output at document start :$read ![cmd] call a native command, append output to document :[n]read ![cmd] call a native command, insert output at line [n] :write ![cmd] call a native command with the document as its input :[range]write ![cmd] call a native command with the range as its input :%![cmd] filter document through a native command :.![cmd] filter a single line through a native command :[n],[m]![cmd] filter lines [n] to [m] through a native command ![motion][cmd] filter lines demarcated by [motion] through a shell cmd !![cmd] filter cusor line through a native command [n]!! filter [n] lines through a native command :!echo % use % to pass the name of current file to shell :w | !clear; ./% save file, clear terminal, then run the current file K open man page for word under cursor gf open file under cursor (go to file) :help filter help page for filters :help filename-modifiers help page for filename-modifiers :help %: help page for filename-modifiers